package com.ruoyi.xh.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TablePageDataInfo;
import com.ruoyi.common.core.domain.CommentResult;
import com.ruoyi.xh.domain.XhSystemMenu;
import com.ruoyi.xh.service.IXhSystemMenuService;

/**
 * 系统-菜单Controller
 *
 * @author songjw
 * @date 2024-12-13
 */
@Api(tags = "系统-菜单Controller",value = "系统-菜单Controller")
@RestController
@RequestMapping("/xh/systemMenu")
public class XhSystemMenuController extends BaseController {

    @Autowired
    private IXhSystemMenuService xhSystemMenuService;

    /**
     * 查询系统-菜单列表
     */
    @PreAuthorize("@ss.hasPermi('xh:systemMenu:list')")
    @GetMapping("/list")
    @ApiOperation("查询系统-菜单列表")
    public TablePageDataInfo<XhSystemMenu> list(XhSystemMenu xhSystemMenu) {
        return TablePageDataInfo.success(xhSystemMenuService.selectXhSystemMenuList(xhSystemMenu));
    }

    /**
     * 获取系统-菜单详细信息
     */
    @PreAuthorize("@ss.hasPermi('xh:systemMenu:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取系统-菜单详细信息")
    public CommentResult<XhSystemMenu> getInfo(@PathVariable("id") String id) {
        return CommentResult.success(xhSystemMenuService.selectXhSystemMenuById(id));
    }

    /**
     * 新增系统-菜单
     */
    @PreAuthorize("@ss.hasPermi('xh:systemMenu:add')")
    @Log(title = "系统-菜单", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增系统-菜单")
    public CommentResult<XhSystemMenu> add(@RequestBody XhSystemMenu xhSystemMenu) {
            xhSystemMenuService.insertXhSystemMenu(xhSystemMenu);
        return CommentResult.success();
    }

    /**
     * 修改系统-菜单
     */
    @PreAuthorize("@ss.hasPermi('xh:systemMenu:edit')")
    @Log(title = "系统-菜单", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改系统-菜单")
    public CommentResult<XhSystemMenu> edit(@RequestBody XhSystemMenu xhSystemMenu) {
            xhSystemMenuService.updateXhSystemMenu(xhSystemMenu);
        return CommentResult.success();
    }

    /**
     * 删除系统-菜单
     */
    @PreAuthorize("@ss.hasPermi('xh:systemMenu:remove')")
    @Log(title = "系统-菜单", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation("删除系统-菜单")
    public CommentResult<XhSystemMenu> remove(@PathVariable String[] ids) {
            xhSystemMenuService.deleteXhSystemMenuByIds(ids);
        return CommentResult.success();
    }
}
